{include file="../../../application/admin/view/public/head" /}
<div class="page-container p10">

    <div class="showpic" style="display:none;"><img class="showpic_img" width="120" height="160"></div>
    
    <form class="layui-form layui-form-pane" method="post" action="">
        <input type="hidden" name="id" value="{$info.id|default=0}">
        <blockquote class="layui-elem-quote layui-quote-nm">
            提示信息：请使用下面的头条图床 以便提升图片加载速度 <br> <a href="https://www.gudian.org/tools/tt.html" target="_blank">点击打开头条图床</a>
        </blockquote>

        <div class="layui-form-item">
            <label class="layui-form-label">显示状态：</label>
            <div class="layui-input-block">
                <input name="is_show" type="radio" id="rad-1" value="0" title="隐藏" {if condition="$info['is_show'] neq 1"}checked {/if}>
                <input name="is_show" type="radio" id="rad-2" value="1" title="显示" {if condition="$info['is_show'] eq 1"}checked {/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序：</label>
            <div class="layui-input-inline w100">
                <input type="text" class="layui-input" value="{$info.sort|default=99}" placeholder="" id="sort" name="sort">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">列表展示数：</label>
            <div class="layui-input-inline w100">
                <input type="text" class="layui-input" value="{$info.limit|default=6}" placeholder="" id="limit" name="limit">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">名称：</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" lay-verify="name" value="{$info.name}" placeholder="" id="name" name="name">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">内容：</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" name="content">{$info.content}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">栏目封面：</label>
            <div class="layui-input-inline w600">
                <input type="text" name="fengmian" placeholder="图片地址或路径" value="{$info['fengmian']}" class="layui-input upload-input">
            </div>
            <div class="layui-input-inline ">
<!--                <button type="button" class="layui-btn layui-upload" lay-data="{data:{thumb:0,thumb_class:'type_pic'}}" id="upload1">上传图片</button>-->
                <a href="https://www.gudian.org/tools/tt.html" target="_blank" class="layui-btn" >头条图床</a>
            </div>
        </div>


        <div class="layui-form-item center">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="formSubmit" data-child="true">保 存</button>
                <button class="layui-btn layui-btn-warm" type="reset">还 原</button>
            </div>
        </div>
    </form>

</div>
{include file="../../../application/admin/view/public/foot" /}
<script type="text/javascript">
    function selectOnChange(id)
    {
        var flag = id;
        var type_tpl = 'type.html';
        var type_tpl_list = 'show.html';
        var type_tpl_detail = 'detail.html';
        var type_tpl_play = 'play.html';
        var type_tpl_down = 'down.html';

        if(flag != 1){
            $(".vod-list").hide();
            type_tpl_play = '';
            type_tpl_down = '';
        }
        else{
            $(".vod-list").show();
        }
        if($('input[name="type_id"]').val() ==''){
            $('input[name="type_tpl"]').val(type_tpl);
            $('input[name="type_tpl_list"]').val(type_tpl_list);
            $('input[name="type_tpl_detail"]').val(type_tpl_detail);
            $('input[name="type_tpl_play"]').val(type_tpl_play);
            $('input[name="type_tpl_down"]').val(type_tpl_down);
        }
    }
    layui.use(['form','upload', 'layer'], function () {
        // 操作对象
        var form = layui.form
                , layer = layui.layer
                , upload = layui.upload
                , $ = layui.jquery;

        upload.render({
            elem: '.layui-upload'
            ,url: "{:url('upload/upload')}?flag=type"
            ,method: 'post'
            ,before: function(input) {
                layer.msg('文件上传中...', {time:3000000});
            },done: function(res, index, upload) {
                var obj = this.item;
                if (res.code == 0) {
                    layer.msg(res.msg);
                    return false;
                }
                layer.closeAll();
                var input = $(obj).parent().parent().find('.upload-input');
                if ($(obj).attr('lay-type') == 'image') {
                    input.siblings('img').attr('src', res.data.file).show();
                }
                input.val(res.data.file);

                if(res.data.thumb_class !=''){
                    $('.'+ res.data.thumb_class).val(res.data.thumb[0].file);
                }
            }
        });

        $('.upload-input').hover(function (e){
            var e = window.event || e;
            var imgsrc = $(this).val();
            if(imgsrc.trim()==""){ return; }
            var left = e.clientX+document.body.scrollLeft+20;
            var top = e.clientY+document.body.scrollTop+20;
            $(".showpic").css({left:left,top:top,display:""});
            if(imgsrc.indexOf('://')<0){ imgsrc = ROOT_PATH + '/' + imgsrc;	} else{ imgsrc = imgsrc.replace('mac:','http:'); }
            $(".showpic_img").attr("src", imgsrc);
        },function (e){
            $(".showpic").css("display","none");
        });

        // 验证
        form.verify({
            type_name: function (value) {
                if (value == "") {
                    return "请输入分类名称";
                }
            },
            type_tpl: function (value) {
                if (value == "") {
                    return "请输入分类页模板";
                }
            }
        });


        form.on('select(type_mid)', function(data){
            selectOnChange(data.value);
        });


        selectOnChange({$info.type_mid});
    });
</script>

</body>
</html>